<?php

namespace app\admin\model\activityone;

use think\Model;
use think\Db;

class Laxin extends Model
{





    // 表名
    protected $name = 'event_invite';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'coupon_text',
        'superiorcoupon_text'
    ];

    public function getCouponTextAttr($value, $data)
    {
        $lists = Db::name('shopro_coupon')
            ->whereIn('id', $data['gift_coupon'])
            ->column('name');
        return implode(',', $lists);
    }
    public function getsuperiorCouponTextAttr($value, $data)
    {
        $lists = Db::name('shopro_coupon')
            ->whereIn('id', $data['superior_gift_coupon'])
            ->column('name');
        return implode(',', $lists);
    }

    public function arealist(){
        $arealist = "select f.* from fa_area f inner join fa_area f1 on f.pid=f1.id where f1.pid=0";
        $res = Db::query($arealist);
      return  $res;
    }


    public function coupon()
    {
        $couponlist = Db::name('shopro_coupon')->order('id desc')->select();
        return $couponlist;
    }

    public function couponsta()
    {
        return $this->belongsTo('\app\admin\model\shopro\Coupon', 'gift_Coupon', 'id', [], 'LEFT')->setEagerlyType(0);

    }

    public function events()
    {
        return $this->belongsTo('app\admin\model\activityone\Activitydetail', 'event_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    // public function arealist(){


    // }












}
